/*
 * some utils for wffs such as hash and crc
 */
#include <string.h>
#include "wffs_utils.h"

int wffs_tea_hash(char *name)
    {
    char *p = &name[0];
    int hash_val = 0;

    if (0 == strcmp(".", name))
        {
        return(1);
        }

    if (0 == strcmp("..", name))
        {
        return(2);
        }


    while (*p)
        {
        if (*p != '/')
            hash_val = ((hash_val << 5) - hash_val) + (*p & 0x0FF);
        p++;
        }

    if (hash_val < 0)
        hash_val = -hash_val;

    return(hash_val);
    }
